﻿using DBHelp.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DBHelp.DAL
{
    public class UserDal
    {
        dbHelpClass dbHelpClass { get; set; }
        public UserDal()
        {
            dbHelpClass = dbHelpClass.GetDBHelp();
            Task.Factory.StartNew(() =>
            {
                Init();
            });
        }
        private async void Init()
        {
            await dbHelpClass.Init<User>();
            User user = new User()
            {
                Name = "admin",
                Passward = "admin",
            };
            await dbHelpClass.SaveItemAsync(user);
        }
        public async Task<User> SelectData(string user)
        {
            return await dbHelpClass.Database.Table<User>().Where(t => t.Name == user).FirstAsync();
        }
    }
}
